#include "include/LoginDialog.h"
#include <qlabel.h>

void LoginDialog::InitWindows() {
    // 设计窗口标题
    this->setWindowTitle("登录页面");
    // 固定窗口大小
    this->setFixedSize(400, 400);

    // 初始化注册页面
    this->RegisterIndex();

    // 创建文本框，并设置其大小策略
    username = new QLineEdit(this);
    username->resize(150,30);
    username->move(150,100);
    QLabel* userNamelable = new QLabel("姓名：",this);
    userNamelable->resize(50, 30);
    userNamelable->move(100, 100);


    password = new QLineEdit(this);
    password->resize(150, 30);
    password->move(150, 150);
    password->setEchoMode(QLineEdit::Password); 
    QLabel* pwdlable = new QLabel("密码：", this);
    pwdlable->resize(50, 30);
    pwdlable->move(100, 150);


    loginButton = new QPushButton("登录",this);
    loginButton->resize(70, 40);
    loginButton->move(100,275);

    registerButton = new QPushButton("注册",this);
    registerButton->resize(70, 40);
    registerButton->move(230, 275);

    // 连接信号和槽
    connect(loginButton, &QPushButton::clicked, this, &LoginDialog::onOpenLoginDialog);
    connect(registerButton, &QPushButton::clicked, this, &LoginDialog::onOpenRegisterDialog);
}

void LoginDialog::RegisterIndex() {
    registerIndex = new QWidget(this);
    registerIndex->setFixedSize(400,400);
    registerIndex->move(400, 0); // 将其定位在主窗口外部

    phone = new QLineEdit(registerIndex);
    phone->resize(150, 30);
    phone->move(150, 200);
    QLabel* pwdlable = new QLabel("电话：", registerIndex);
    pwdlable->resize(50, 30);
    pwdlable->move(100, 200);

    registerIndex->hide();
}
